
<%@ page import="pc.system.*,wstrader.*,wstrader.task.*" %>

<%
    Users user = Trader.getUser(request.getParameter("uid"));
	
        if (user == null || !user.Authenticated()) {
                response.sendRedirect("logon.jsp");	
                return;
        }
	
        wstrader.task.trade.Futures ftask = user.trade.futures;
        wstrader.task.trade.futures.Transactions task = user.trade.futures.transactions;
        ((Tasks)ftask.getOwner()).clearFocus();
        ftask.setFocus(true);
        //ftask.forwardToChild(user.getuid());	
        ResultSet rs;		
%>

<%@include file="../header.jsp"%>

<%
        long focused_id = task.doTask();
        //if (focused_id <= 0) focused_id = 1;
        //Record rc   = task.getRecord("purchase_contract",focused_id);
%>

<link href="style.css" rel="stylesheet" type="text/css">

<script language="javascript">
    
    $(document).ready(function(){
        getTableData();
    });
    
    function getTableData(){
        var cnt_dt = $("#cnt_dt").val();
        var bot_sold = $("#bot_sold").val();
        var ter_mrk = $("#ter_mrk").val();
        var broker = $("#broker").val();
        var ter_mth = $("#ter_mth").val();        
        var uid = $("#uid").val();
        //var table_length = $("#table_length").val();
        var data = "cnt_dt=" + cnt_dt + "&bot_sold=" + bot_sold + "&ter_mrk=" + ter_mrk + "&broker=" + broker + "&ter_mth=" + ter_mth + "&uid=" + uid;
        $.ajax({
            type: "GET",
            url: "trade.futures.transactions.ajax-source.jsp",
            data: data,
            success: function(msg){
                $("#table_data").html(msg);
            }
        });        
    }
    
    function doAddNew()
    {
        var form = document.formMain;
        form.new_rec.value = "1";
        form.action = "trade.futures.transactions.card.jsp";
        form.submit();
    }

    function doFilter()
    {
        var form = document.formMain;
        form.action = "trade.futures.jsp";
        form.submit();
    }

    function clickCardView(row)
    {
        var form = document.formMain;
        if (row == null) row = old_row_obj;
        form.action = "trade.futures.transactions.card.jsp";
        form.submit();	
    }

    function doCloseOut()
    {
        var form = document.formMain;
        var sold = form.tot_cl_sold.value;
        var bot = form.tot_cl_bot.value
	
        if ((sold-bot) == 0) 
        {
            doTask(3);
        }
        else
        {
            alert("No of bot closed does not match with no of sold closed");	
        }

    }

    function cardViewClick(row)
    {
        var form = document.formMain;
        form.futures_contract.value = (row.id).substring(2);
        dblClick(row);
    }
    
</script>
<style type="text/css">
    <!--
    .style3 {font-family: Arial}
    .style6 {font-size: 12px}
    -->
</style>
<form action="" method="post" name="formMain" id="formMain">

    <fieldset style=" background: #eee; margin-bottom: 20px; margin-top: 20px;">
        <span class="style2 style3"  style="font-weight: bold;">Transaction Date </span>
        <select name="cnt_dt" id="cnt_dt" style="font-size: 11px" onchange="getTableData()">
            <%@include file="include/FuturesContractDateList.jsp"%>
        </select>
        <span class="style2 style3"  style="font-weight: bold;">Bot/Sold </span>
        <select name="bot_sold" id="bot_sold" style="font-size: 11px" onchange="getTableData()">
            <option value="0" selected>All</option>
            <option value="B">BOT</option>
            <option value="S">SOLD</option>
            <%task.getResponse().setSelected("bot_sold");%>
        </select>
        <span class="style2 style3"  style="font-weight: bold;">Terminal Market </span>
        <select name="ter_mrk" id="ter_mrk" style="font-size: 11px" onchange="getTableData()">
            <option value="0" selected>All</option>
            <option value="NYC">NYC</option>
            <option value="LIFFE">LIFFE</option>
            <%task.getResponse().setSelected("ter_mrk");%>
        </select>
        <span class="style2 style3"  style="font-weight: bold;">Broker </span>
        <select name="broker" id="broker" style="font-size: 11px" onchange="getTableData()">
            <option value="0" selected>All</option>
            <%
                    task.getResponse().setOption("futures_account_master","name");
                    task.getResponse().setSelected("broker");
            %>
        </select>
        <span class="style2 style3"  style="font-weight: bold;">Terminal Month </span>
        <select name="ter_mth" id="ter_mth" style="font-size: 11px" onchange="getTableData()">
            <%@include file="include/TerminalMonthList.jsp"%>
        </select>
    </fieldset>
    <div id="table_data"></div>
    
    <table width="100%"  border="0" cellpadding="1" cellspacing="1">
        <tr>
            <td>
                <img src="images/new.gif"  onclick="doAddNew();" width="15" height="15" />
            </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td colspan="2" align="right"><strong><span class="style29 style3 style6">Close Out Date: </span></strong></td>
            <td width="134" align="right"><input name="close_out_date" type="text" id="close_out_date" style="width:88px">      </td>
            <td width="33" align="left"><img src="js/calendar.gif" width="20" height="20" align="absmiddle" onClick="popUpCalendar(this,'close_out_date','dd-mmm-yy');"></td>
            <td width="59" align="center" valign="middle"><img src="images/close-out.jpg" width="55" height="18" onClick="doCloseOut();"></td>
            <td width="65" align="center"><img src="images/cardview.jpg" width="55" height="18" onClick="clickCardView()"></td>
        </tr>
    </table>    
    <input type="hidden" name="uid"        id="uid"       value="<%=user.getuid()%>">
    <input type="hidden" name="task_id"    id = "task_id"   value="0">
    <input type="hidden" name="new_rec"    id = "new_rec"   value="0" />
</form>
<%@include file="../footer.jsp"%>

